package xin.marcher.module.label.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xin.marcher.module.label.domain.dto.ProductLabelRelationResultDTO;
import xin.marcher.module.label.domain.request.ProductLabelRelationRequest;
import xin.marcher.module.label.repository.LabelRelationRepository;
import xin.marcher.module.label.service.ProductLabelRelationService;

import java.util.List;

/**
 *
 */
@Service
public class ProductLabelRelationServiceImpl implements ProductLabelRelationService {

    @Autowired
    private LabelRelationRepository labelRelationRepository;

    @Override
    public ProductLabelRelationResultDTO saveProductLabelRelation(List<ProductLabelRelationRequest> request) {
        // 先删除所有的标签
        labelRelationRepository.removeProductLabelRelation(request);
        // 然后保存标签
        return labelRelationRepository.saveProductLabelRelation(request);
    }
}
